//
//  NSString+Utils.m
//  XJMTechnician
//
//  Created by 高波 on 2019/1/7.
//  Copyright © 2019 Mr.hu. All rights reserved.
//

#import "NSString+Utils.h"
#import <AdSupport/AdSupport.h>

@implementation NSString (Utils)

+ (NSString *)timestampStr {
    NSDate *date = [NSDate dateWithTimeIntervalSinceNow:0];//获取当前时间0秒后的时间
    NSTimeInterval time = [date timeIntervalSince1970] * 1000;// *1000 是精确到毫秒，不乘就是精确到秒
    NSString *timeString = [NSString stringWithFormat:@"%.0f", time];
    return timeString;
}

+ (NSString *)fileKey
{
    NSString *timeStr = [NSString timestampStr];
    NSString *adId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
    NSString *key = [adId stringByAppendingString:timeStr];
    
    NSInteger random1 = arc4random() / 10000;
    NSInteger random2 = arc4random() / 10000 + 1000;
    
    key = [key stringByAppendingString:[NSString stringWithFormat:@"%ld",(long)random1]];
    key = [key stringByAppendingString:[NSString stringWithFormat:@"%ld",(long)random2]];
    
    return key;
}

@end
